-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
ENH: fill_value argument for shift #15486 #24128
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
!I master -> fork
Hello @ahcub! Thanks for updating the PR. Cheers ! There are no PEP8 issues in this Pull Request. 🍻 Comment last updated on December 26, 2018 at 00:17 Hours UTC |
Codecov Report
@@ Coverage Diff @@
## master #24128 +/- ##
==========================================
+ Coverage 92.29% 92.3% +0.01%
==========================================
Files 162 163 +1
Lines 51832 51978 +146
==========================================
+ Hits 47839 47980 +141
- Misses 3993 3998 +5
Continue to review full report at Codecov.
|
Codecov Report
@@ Coverage Diff @@
## master #24128 +/- ##
===========================================
- Coverage 92.2% 43.03% -49.18%
===========================================
Files 162 162
Lines 51701 51701
===========================================
- Hits 47672 22247 -25425
- Misses 4029 29454 +25425
Continue to review full report at Codecov.
|
@@ -320,6 +320,19 @@ def test_shift_categorical(self): | |||
xp = DataFrame({'one': s1.shift(1), 'two': s2.shift(1)}) | |||
assert_frame_equal(rs, xp) | |||
|
|||
def test_shift_fill_value(self): | |||
df = DataFrame(np.random.randnint(5), index=date_range('1/1/2000', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add the gh number as a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably need to add to Categorical, SparseArray. What about groupby?
added fill_value to shift implementations across different classes, according to the failures from tests |
@jreback I made all the changes, except the Index subclasses, because I think Index doesn't need fill_value. it does the shift correctly already with the freq specified |
One last linting error as well:
|
used isort to fix those, hopefully no issues this time 🙏 |
just added the whatsnew note, not sure if it is ok |
all green @jreback |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
2 tiny corrections. ping on green and will merge. thanks for being so responsive.
doc/source/whatsnew/v0.24.0.rst
Outdated
@@ -31,6 +31,7 @@ New features | |||
- :func:`read_feather` now accepts ``columns`` as an argument, allowing the user to specify which columns should be read. (:issue:`24025`) | |||
- :func:`DataFrame.to_html` now accepts ``render_links`` as an argument, allowing the user to generate HTML with links to any URLs that appear in the DataFrame. | |||
See the :ref:`section on writing HTML <io.html>` in the IO docs for example usage. (:issue:`2679`) | |||
- :meth:`DataFrame.shift` :meth:`Series.shift`, :meth:`ExtensionArray.shift`, :meth:`SparseArray.shift`, :meth:`Period.shift`, :meth:`GroupBy.shift`, :meth:`Categorical.shift`, :meth:`NDFrame.shift` and :meth:`Block.shift` now accept fill_value as an argument, allowing the user to specify a value which will be used instead of NA/NaT in the empty periods |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you use double backticks on fill_value
and add a reference to the issue.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added
@@ -9,6 +9,8 @@ | |||
from pandas.compat import range | |||
import pandas.util._test_decorators as td | |||
|
|||
from pandas.core.dtypes.missing import isna |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in tests just
from pandas import isna
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
changed
@ahcub lgtm. ping on green. |
all green @jreback |
thanks @ahcub this was a pretty involved change, thanks for sticking with it! |
thank you for all the support! |
* upstream/master: (26 commits) DOC: Fixing doc upload (no such remote origin) (pandas-dev#24459) BLD: for C extension builds on mac, target macOS 10.9 where possible (pandas-dev#24274) POC: _eadata (pandas-dev#24394) DOC: Correct location (pandas-dev#24456) CI: Moving CircleCI build to Travis (pandas-dev#24449) BUG: Infer compression by default in read_fwf() (pandas-dev#22200) DOC: Fix minor typo in whatsnew (pandas-dev#24453) DOC: Add dateutil to intersphinx pandas-dev#24437 (pandas-dev#24443) DOC: Adding links to offset classes in timeseries.rst (pandas-dev#24448) DOC: Adding offsets to API ref (pandas-dev#24446) DOC: fix flake8 issue in groupby.rst (pandas-dev#24363) DOC: Fixing more doc warnings (pandas-dev#24438) API: Simplify repeat signature (pandas-dev#24447) BUG: to_datetime(Timestamp, utc=True) localizes to UTC (pandas-dev#24441) CLN: Cython Py2/3 Compatible Imports (pandas-dev#23940) DOC: Fixing more doc warnings (pandas-dev#24431) DOC: Removing old release.rst (pandas-dev#24427) BUG-24408 Series.dt does not maintain own copy of index (pandas-dev#24426) DOC: Fixing several doc warnings (pandas-dev#24430) ENH: fill_value argument for shift pandas-dev#15486 (pandas-dev#24128) ...
git diff upstream/master -u -- "*.py" | flake8 --diff